/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: SwaggerConfig
 * Author:   李毅
 * Date:     2019/10/17 15:02
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.ymtms.supplycar.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 〈一句话功能简述〉<br> 
 * 〈swagger配置类〉
 *
 * @author 李毅
 * @create 2019/10/17
 * @since 1.0.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())//api的说明信息
                .useDefaultResponseMessages(false)
                .select()
                //选定要生成API的接口或者类的父包
                .apis(RequestHandlerSelectors.basePackage("com.ymtms.supplycar.controller"))
                .paths(PathSelectors.any()) //路径规则，这里是包中所有
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("xxx项目-主业务模块API")
                .description("xxx项目-主业务模块API-描述信息")
                .termsOfServiceUrl("http://127.0.0.1:8080")
                .contact(new Contact("作者","访问地址","联系方式"))
                .build();
    }
}